//
//  ChooseTypeCollectionViewCell.m
//  TourPlay
//
//  Created by dllo on 15/11/26.
//  Copyright © 2015年 王军岐. All rights reserved.
//

#import "ChooseTypeCollectionViewCell.h"

@interface ChooseTypeCollectionViewCell ()

@property (nonatomic, retain) UIView *onView;
@property (nonatomic, retain) UIView *offView;
@property (nonatomic, retain) UILabel *titleL;
@property (nonatomic, retain) UIImageView *imageV;

@end

@implementation ChooseTypeCollectionViewCell
- (void)dealloc
{
    [_onView release];
    [_offView release];
    [_titleL release];
    [_imageV release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
- (void)createSubViews
{
    self.offView  = [[UIView alloc] initWithFrame:self.contentView.bounds];
    self.offView.backgroundColor = [UIColor clearColor];
    self.offView.layer.cornerRadius = 18.f * AUTOSCREEN_HEIGHT;
    // 边框宽度
    self.offView.layer.borderWidth = 1;
    // 边框颜色
//    self.offView.layer.borderColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1].CGColor;
    [self.contentView addSubview:self.offView];
    [_offView release];
    
    self.onView  = [[UIView alloc] initWithFrame:self.contentView.bounds];
    self.onView.backgroundColor = [UIColor clearColor];
    self.onView.layer.cornerRadius = 18.f * AUTOSCREEN_HEIGHT;
    // 边框宽度
    self.onView.layer.borderWidth = 1;
    self.onView.hidden = YES;
    // 边框颜色
//    self.onView.layer.borderColor = [UIColor colorWithRed:0.96 green:0.67 blue:0.68 alpha:1].CGColor;
    [self.contentView addSubview:self.onView];
    [_onView release];
    
    
    [self addColorChangedBlock:^{
        
        self.offView.layer.borderColor = [ColorSingleton shareSingleton].offViewBorderColor.CGColor;
        self.onView.layer.borderColor = [ColorSingleton shareSingleton].onViewBorderColor.CGColor;
    }];
    

    
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.contentView.frame.size.width - 13 * AUTOSCREEN_WIDTH, 0, 13 * AUTOSCREEN_WIDTH, 13 * AUTOSCREEN_WIDTH)];
    self.imageV.image = [UIImage imageNamed:@"category_select_check@2x.png"];
    self.imageV.hidden = YES;
//    imageV.backgroundColor = [UIColor blackColor];
    [self.contentView addSubview:self.imageV];
    [_imageV release];
    

    self.titleL = [[UILabel alloc] initWithFrame:self.offView.bounds];
    self.titleL.adjustsFontSizeToFitWidth = YES;
    self.titleL.font = [UIFont systemFontOfSize:15.f * AUTOSCREEN_WIDTH];
    self.titleL.textAlignment = NSTextAlignmentCenter;
    self.titleL.textColor = [UIColor colorWithRed:0.36 green:0.33 blue:0.33 alpha:1];
    [self.contentView addSubview:self.titleL];
    [_titleL release];
    
}
- (void)setWithisOn:(BOOL)isOn
{
    if (isOn) {
        self.onView.hidden = NO;
        self.imageV.hidden = NO;
    } else {
        self.onView.hidden = YES;
        self.imageV.hidden = YES;
    }
}
- (void)setTypeMod:(TypeTitleModel *)typeMod
{
    if (_typeMod != typeMod) {
        [_typeMod release];
        _typeMod = [typeMod retain];
    }
    self.titleL.text = self.typeMod.titleName;
}
@end
